const express = require('express');
const router = express.Router();

router.get('/', (req, res) => {
    const content = [];
    const {pageIndex, pageSize} = req.query;
    for(let i = 0; i <= 100; i++) content.push({
        id: `${i + 1}`,
        manufacturerCode: `201900${i}`,
        manufacturerName: `JXSMC00${i}`,
        productCategoryCode: `201900${i}`,
        productCategoryName: `Eng${i}`,
        remark: 'remark',
        areaName: '重庆市渝北区',
        needTransportScanning: true,
        isOffsiteFactory: false,
        status: 1,
        options: [
            'update',
            'abandon',
            'maintain'
        ]
    });
    res.json({
        message: '',
        payload: {
            content,
            pageIndex: parseInt(pageIndex, 10),
            pageSize: parseInt(pageSize, 10),
            totalElements: 100,
        }
    });
});

router.get('/:id', (req, res) => {
    res.json({
        message: 'string',
        payload: {
            id: '1',
            brandId: 'brandId',
            brandCode: 'brandCode',
            code: 'DSAFFA',
            name: '奇瑞国际1,奇瑞国际2,奇瑞国际3',
            areaId: '1',
            areaName: 'areaName',
            countryId: '2',
            countryName: 'countryName',
            provinceId: '3',
            provinceName: 'provinceName',
            cityId: '4',
            cityName: 'cityName',
            address: 'address',
            contactNumber: 'contactNumber',
            fax: 'fax',
            needTransportScanning: true,
            isOffsiteFactory: true,
            remark: 'remark',
            rowVersion: 'string',
        }
    });
});

router.get('/:id/forMaintain', (req, res) => {
    res.json({
        message: 'string',
        payload: {
            id: '1',
            code: 'DSAFFA',
            name: '奇瑞国际1,奇瑞国际2,奇瑞国际3',
            areaName: '重庆市渝北区',
            needTransportScanning: true,
            isOffsiteFactory: true,
            status: 1,
            remark: 'remark',
            rowVersion: 'string',
            options: [
                'update',
                'abandon',
                'maintain'
            ],
            productCategories: [
                {
                    id: '1',
                    code: 'DASAFAD-1',
                    name: 'a产品'
                },
                {
                    id: '2',
                    code: 'DASAFAD-2',
                    name: 'b产品'
                },
                {
                    id: '3',
                    code: 'DASAFAD-3',
                    name: 'c产品'
                }
            ]
        }
    });
});

router.post('/', (req, res) => {
    res.json({
        message: '新增成功'
    });
});

router.put('/:id', (req, res) => {
    res.json({
        message: '编辑成功'
    });
});

router.put('/:id/abandon', (req, res) => {
    res.json({
        message: '作废成功'
    });
});

router.put('/:id/maintain', (req, res) => {
    res.json({
        message: '关系维护成功'
    });
});

module.exports = router;
